import { koiMsgBox } from "./koi";

import router from "../routers/index.ts";

export const exportAction = async (fn: Function) => {
  koiMsgBox("您确认要以当前条件进行导出吗？")
    .then(async () => {
      await fn();
      koiMsgBox("您的导出任务已加入，请稍后在导出中心进行下载", "温馨提示", "前往导出中心", "留在当前页面", "success")
        .then(() => {
          setTimeout(() => {
            router.push({ path: "/plugin/exportcenter/exportcenter/index" });
          }, 500);
        })
        .catch(e => {
          console.log(`e1`, e);
        });
    })
    .catch(e => {
      console.log(`e2`, e);
    });
};
